package ihm;

import java.awt.event.ActionListener;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JToolBar;
import javax.swing.SwingConstants;

import elubrication.MumWindow;

public class BarreOutil extends JToolBar {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private MumWindow _mainFrame;
	
	protected MumWindow getMainFrame() {
		return this._mainFrame;
	}
	
	private ActionListener _myActionListener; 
	
	public void setMyActionListener(ActionListener _myActionListener) {
		this._myActionListener = _myActionListener;
	}

	public ActionListener getMyActionListener() {
		return _myActionListener;
	}
	
	public BarreOutil(MumWindow mainFrame) {
		this(mainFrame, SwingConstants.HORIZONTAL);
	}
	
	public BarreOutil(MumWindow mainFrame, int orientation) {
		
		super(orientation);
		
		setFloatable(false);
		
		this._mainFrame = mainFrame;
	}
	
	public JButton makeButton(String imageName,
								String actionCommand,
								String toolTipText,
								String altText) {
		
		JButton button = new JButton();
		
		button.setActionCommand(actionCommand);
		button.setToolTipText(toolTipText);
		button.addActionListener(_myActionListener);
		
		imageName = "/media/Data/Workspace/Java/Projet/" + imageName;
		button.setIcon(new ImageIcon(imageName, altText));
		
        add(button);
		return button;
	}
}
